#!/bin/bash

if [ `whoami` != "root" ]; then
    echo "需要以root用户执行"
    exit -1;
fi

python=Python-3.8.0
pythontar="$FILEDD"$python.tgz
if [ ! -f $pythontar ]; then
    echo $pythontar 文件不存在-需要指定文件所在目录
    exit -1;
fi

# 离线安装python
echo 开始安装-------------- $python
tar -zxvf $pythontar
pushd $python
./configure --prefix=${HOME}/python3.8.0 --enable-loadable-sqlite-extensions --enable-shared
make
make install

# 添加python的环境变量
echo "#py_begin" >> ~/.bashrc
sed -i '$a export LD_LIBRARY_PATH=${HOME}/python3.8.0/lib:$LD_LIBRARY_PATH' ~/.bashrc
sed -i '$a export PATH=${HOME}/python3.8.0/bin:$PATH' ~/.bashrc
echo "#py_end" >> ~/.bashrc
source ~/.bashrc

# 配置pip源
cp pip.conf ~/.pip/pip.conf
popd
rm -rf $python
echo 安装------------------$python 完成

